<%@ page language="java" contentType="text/html;charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@include file="../common/taglib.jsp"%>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>
<html>
<head>
	<meta charset="UTF-8">
	<title>体温监控系统</title>
	<link rel="stylesheet" type="text/css" href="${ctx }/static/css/normalize.css">
	<link rel="stylesheet" type="text/css" href="${ctx }/static/css/common.css">
	<script type="text/javascript" src="${ctx }/static/js/jquery.min.js"></script>
	<script src="${ctx }/highcharts/highcharts.js"></script>
	<script src="${ctx }/modules/exporting.js"></script>
	<script src="${ctx }/static/js/common.js"></script>
	<script src="${ctx }/static/js/My97DatePicker/WdatePicker.js"></script>
    <style>
		.main{width:980px; margin:0px auto;}
		.roombox{margin: 10px 0px;}
		.roombox .title{ font-size: 16px; font-family:  "Microsoft YaHei","微软雅黑";color: #0191ff}
		.roombox .bedbox > li{ position: relative; font-family:  "Microsoft YaHei","微软雅黑"; font-size: 14px; border: solid 1px #d5d5d5; height: 200px; margin:10px 0px 0px 0px; float: left; width: 150px;margin-right: 11px;}
		.roombox .bedbox > li .printbox{ display: none; position: absolute; height: 450px; width: 300px; left: 6px; top: 40px; background: #fff;}
		.roombox .bedbox > li .printbox img{ display: block; width: 250px; height: 375px; margin: 10px auto 15px auto;}
		.roombox .bedbox > li .printbox .printbt{ width: 80px; height: 30px; line-height: 30px; text-align: center; color: #fff; background: #0091ff; border-radius: 3px; display: block; margin: 0 auto; }
		.roombox .bedbox > li .lititle{ height: 40px; line-height: 40px; padding: 0px 10px;}
		.roombox .bedbox > li .lititle span{  font-size:18px}
		.roombox .bedbox > li .lititle .contralbox{ float: right;}
		.roombox .bedbox > li .lititle .contralbox span{ display: inline-block}
		.roombox .bedbox > li .lititle .contralbox .showinfo{ background: url("${ctx }/images/close.png") no-repeat; background-position:0px -20px;width: 18px; height: 18px; margin: 0px 5px; margin-top: 8px; cursor: pointer}
		.roombox .bedbox > li .lititle .contralbox .showinfo:hover{background-position:-22px -20px;}
		.roombox .bedbox > li .lititle .contralbox .close{ background: url("${ctx }/images/close.png") no-repeat; background-position:0px -40px;width: 18px; height: 18px; margin: 0px 5px; margin-top: 8px; cursor: pointer}
		.roombox .bedbox > li .lititle .contralbox .close:hover{background-position:-22px -40px;}
		.roombox .bedbox > li .personinfo{margin: 0px 15px;}
		.roombox .bedbox > li .personinfo div{height: 25px; line-height: 25px; margin: 10px 0px;font-size:14px}
		.roombox .bedbox > li .personinfo div.line{ border-top: solid 1px #d5d5d5; height: 1px; margin: 8px 0px;}
		.roombox .bedbox > li .degree{width: 100%}
		.roombox .bedbox > li .degree.high{ height: 115px;background: url("${ctx }/images/degreebg.png");background-position:225px 0px; color: #fd7d7c}
		.roombox .bedbox > li .degree.normal{height: 115px; background: url("${ctx }/images/degreebg.png"); background-position:225px -250px; color: #a7b7c3;}
		.roombox .bedbox > li .degree.low{ height: 115px;background: url("${ctx }/images/degreebg.png"); background-position:225px -125px; color: #35a8ff}
		.roombox .bedbox > li .degree .degreebox{ display: inline-block; margin-left: 12px; margin-top:40px; font-size: 16px; text-align: center}
		.roombox .bedbox > li .degree .degreebox .num{ font-size: 24px;margin-left: 20px}
		.roombox .bedbox > li .listenbt{ margin: 0px 15px; height: 38px; border: solid 1px #0191ff; border-radius:3px; line-height: 38px; text-align: center; color: #0191ff; font-size: 16px; margin-top: 7px; cursor: pointer}
		.roombox .bedbox > li .addbedbg{ background: url("${ctx }/images/addicon.png") no-repeat  center center ; background-position:center 0px; margin-top: 30px; height: 92px;}
		.roombox .bedbox > li .addbedtext{ text-align: center; color: #0191ff; font-size: 16px;}
		.roombox .bedbox > .addperson{cursor: pointer}
		.roombox .bedbox > .addbed{cursor: pointer}
		.roombox .bedbox > li .addpersonbg{ background: url("${ctx }/images/addicon.png") no-repeat  center center ; background-position:center -100px; height: 92px;}
		.roombox .bedbox > li .addpersontext{ text-align: center; color: #0191ff; font-size: 16px;}

		.bedmoreinfo{ width: 651px; border: solid 1px #ccc; display: none; position:  absolute; background: #fff; border-left: none;font-family:  "Microsoft YaHei","微软雅黑";}
		.bedmoreinfo .text{height: 25px; line-height: 25px; margin: 0px 0px; margin-left: 60px; font-size: 14px}
		.changeBedDialog{ width: 250px; border: solid 1px #ccc; display: none; position:  absolute; background: #fff; font-family:  "Microsoft YaHei","微软雅黑";}
		.changeBedDialog .text{height: 25px; line-height: 25px; margin: 0px 0px; margin-left: 60px; font-size: 14px}
		.infobox{ background: #e69138; height: 40px; line-height: 40px; color: #fff; padding: 0px 10px;font-family:  "Microsoft YaHei","微软雅黑"; font-size: 16px; width: 946px;}
		.infobox .closeinfo{ font-size:12px; float: right; display: inline-block}
		.infobox .closeinfo .closecirle{ cursor: pointer; display: inline-block; background: url("${ctx }/images/close.png") no-repeat; background-position:0px 0px; width: 18px; height: 18px; margin: 0px 5px; vertical-align: middle; margin-top: -4px;}



	</style>
	<script>
		//bedinfo.json是获取所有病床信息文件
		//addbed.json是添加病床返回数据
		//addperson.json是添加病人返回数据
		//returnTrue.json是所有返回ture或false的文件
		var bedsinfo = {};//当前所有病床的信息
		var bedsBasicinfo = {};
		var bedsOtherinfo = {};//当前所有病床的其他信息
		var chartObj = {};//当前chart表对象
		var nowDelBed = {};//当前要删除的病房
		var nowAddPersonBed = {};//当前要添加病人的病床
		var nowStopBed = {};//当前要停止监控的病床
		var nowaddBed = {};//当前要添加的病床
		var startHour=2;//折线图从几时开始
		var outpatientid="";//当前要出院的病人
		var currentBedId="";//鼠标悬停后存储当前床位id
		var currentBedName="";//鼠标悬停后存储当前床位名称
		var autorefresh;
		function getClientHeight(){
			return  document.body.scrollHeight > document.documentElement.scrollHeight?document.body.scrollHeight:document.documentElement.scrollHeight;
		}
		function getClientWidth(){
			return  document.body.scrollWidth > document.documentElement.scrollWidth?document.body.scrollWidth:document.documentElement.scrollWidth;
		}
		//初始化调用方法
		$(function(){
			var clientHeight = getClientHeight();
			$(".formbox").height(clientHeight - 281);
			$(".confirmoutbox").hide();
			getBedsData();
			//autorefresh = setTimeout("location.reload(true)", 30000);//自动刷新页面
			autorefresh = setInterval("getBedsData()", 30000);//自动刷新页面
		})
		//停止页面自动刷新
		function stopAutoRefresh() {
			clearTimeout(autorefresh);
		}
		//监听开始或停止监控按钮//rxz 病人出院
		function listenListenBt(){
			$(".listenbt").click(function(){
				/* var patientid=$(this).attr("patientid");
				outpatientid=patientid; 20160122*/
				$('.modelbg').show();
				$(".confirmoutbox").show();
				
				return;
				nowStopBed = $(this).parents("li").first();
				
				if($(this).text() == "终止监控"){
					//stopListen(this);
					$(".modelbg").show();
					$(".confirmstopbox").show();
				}else{
					startListen(this);
				}
			})
		}
		
		function patientout(){
			$.ajax({
		        type:"post",
		        url:"../patient/patientout.action",//��Ӳ�����Ϣ
		        dataType:"json",
		        data:{"id":outpatientid},
		        success:function(data){
		        	if(data.success == false){ 
		        		//alert(data.bedstatus);
						alert("操作失败！");
						return;
					}
		            location.reload(true);
		        }

		    })
		}
		//转科室
		function changeDepartment(){
			$(".bedmoreinfo").hide();
			//初始化部门列表
			$.ajax({
		        type:"post",
		        url:"listDepartments.action",//��Ӳ�����Ϣ
		        dataType:"json",
		        data:{},
		        success:function(data){
		        	if(data.success == false){ 
		        		//alert(data.bedstatus);
						alert("操作失败！");
						return;
					}
		        	$("#selDepartment").empty(); 
		            for(var i=0;i<data.length;i++){
		            	$("#selDepartment").append("<option value='"+data[i].id+"'>"+data[i].name+"</option>"); //为Select追加一个Option(下拉项) 
		            }
		            if(data.length>0){
		            	InitBedsByDepartment();
		            }
		        }

		    })
		    var h = $(window).height();  
                var w = $(window).width();  
                var st = $(window).scrollTop();  
                var sl = $(window).scrollLeft();  
			$(".changeBedDialog").css({"left":((w-250)/2)+sl+"px","top":((h-125)/2)+st+"px"}).show();	
		}
		function InitBedsByDepartment(){
			var departmentId=$("#selDepartment").val();
			//jQuery("#select1  option:selected").text();
			$.ajax({
		        type:"post",
		        url:"getBedsByDepartmentId.action",//��Ӳ�����Ϣ
		        dataType:"json",
		        data:{"departmentId":departmentId},
		        success:function(data){
		        	if(data.success == false){ 
		        		//alert(data.bedstatus);
						alert("操作失败！");
						return;
					}
		            $("#selBed").empty(); 
		            for(var i=0;i<data.length;i++){
		            	$("#selBed").append("<option value='"+data[i].id+"'>"+data[i].name+"</option>"); //为Select追加一个Option(下拉项) 
		            }
		        }

		    })
		}
		//确认转科室
		function sureChangeDepartment(){
			/* alert(outpatientid);
			alert(currentBedName);
			alert(currentBedId); */
			$.ajax({
		        type:"post",
		        url:"../patient/changeBed.action",//��Ӳ�����Ϣ
		        dataType:"json",
		        data:{"patientid":outpatientid,"oldbedid":currentBedId,"newbedid":$("#selBed").val()},
		        success:function(data){
		        	if(data.success == false){ 
		        		//alert(data.bedstatus);
						alert("操作失败！");
						return;
					}
		            location.reload(true);
		        }

		    })
		}
		//开始监听
		function startListen(obj){
			$.ajax({
				type:"post",
				url:"tiwen/returnTrue.json",
				dataType:"json",
				data:{},
				success:function(data){

				}
			})
		}
		//停止监听
		function stopListen(obj){
			$.ajax({
				type:"post",
				url:"tiwen/returnTrue.json",
				dataType:"json",
				data:{},
				success:function(data){
					if(data.success){
						var thisId = +$(nowStopBed).attr("id");
						if($(nowStopBed).parents(".abnormalbeds").length != 0){
							$(nowStopBed).remove();
						}else{
							$(".abnormalbeds").find("#"+thisId+"").remove();
						}
						$(".normalbeds").find("#"+thisId+"").attr("class","addperson")
						$(".normalbeds").find("#"+thisId+"").html('<div class="lititle"><span class="">'+$(nowStopBed).attr("id")+'</span><span class="contralbox"><span class="close"></span> </span></div>' +
								'<div class="addpersonbg"></div><div class="addpersontext"> +病人入住</div>');
						$('.modelbg').hide();$('.confirmstopbox').hide();
						listenAddBed();
						listenAddPerson();
						listenBedHover();
						listenListenBt();
						listenCloseTishi();
						listenShowPrint();
						listenDelBed();
					}
				}
			})
		}
		//监听添加病床
		function listenAddBed(){
			$(".addbed").off("click")
			$(".addbed").click(function(){
				//stopAutoRefresh();//停止自动刷新页面
				nowaddBed = this;
				$('.modelbg').show();
				$(".putbedidbox").show();
			})
			var  nowDiffentcount = $(".abnormalbeds").find("li").length;
			if(nowDiffentcount == 0){
				$(".infobox").hide();
			}else{
				$(".highcount").text(nowDiffentcount)
			}
			$(".totalcount").text($(".normalbeds").find("li").length-1)
		}
		//监听添加病人
		function listenAddPerson(){
			$(".addpersonclick").off("click");//addperson
			$(".addpersonclick").click(function(){
				//stopAutoRefresh();//停止自动刷新页面
				//event.stopPropagation();
				//if(event.target!=this) return;//防止触发两个事件
				nowAddPersonBed = this;
				//$('.addpersonbox').show();$('.modelbg').show()
				openAddPerson();
				$("#bedid").val(nowAddPersonBed.getAttribute("bedName"));
			})
		}
		//监听关闭提示框
		function listenCloseTishi(){
			$(".closecirle").off("click")
			$(".closecirle").click(function(){
				//stopAutoRefresh();//停止自动刷新页面
				$(".infobox").fadeOut();
			})
		}
		//监听点击显示打印表单
		function listenShowPrint(personId){
			$(".showinfo").off("click")
			$(".showinfo").click(function(){
				//var tempprintbox = $(this).parents(".normal").find(".printbox");
				//var  imgurl = $(tempprintbox).attr("imgurl")
				//if($(tempprintbox).css("display") == "none"){
					//$(tempprintbox).find("img").attr("src",imgurl)
					//$(tempprintbox).show();
				//}else{
					//$(tempprintbox).hide();
				//}
				/* var id=$(this).parents(".normal").attr('patientid'); */
				var id=outpatientid;//$(this).attr('patientid');20160122
				window.open('../show/export.action?id='+id);
			})
		}
		//监听删除病床和出院 
		function listenDelBed(){
			$(".close").off("click")
			$(".close").click(function(){
				if($(this).parents(".addperson").length != 0){
					nowDelBed = $(this).parents(".addperson");
				}else{
					nowDelBed = $(this).parents(".normal");
				}
				//stopAutoRefresh();//停止自动刷新页面
				$(".modelbg").show();
				$(".confirmbox").show();
			})
			//监听确认删除病床
			$(".yes").off("click")
			$(".yes").click(function(){
				delbed();
			})
			//监听确认出院
			$(".yesout").off("click")
			$(".yesout").click(function(){
				patientout();
			})
			$(".cancel").off("click")
			$(".cancel").click(function(){
				$(".modelbg").hide();
				$(".confirmbox").hide();
			})
		}

		//删除病床
		function delbed(){
			var bedid = $(nowDelBed).attr("id");
			$.ajax({
				type:"post",
				url:"deleteByName.action",//"returnTrue.json",//此处返回true或false
				dataType:"json",
				data:{bedid:bedid},
				success:function(data){
					var thisId = +$(nowDelBed).attr("id");
					if($(nowStopBed).parents(".abnormalbeds").length != 0){
						$(nowStopBed).remove();
					}
					$(".normalbeds").find("#"+thisId+"").remove();
					$(".abnormalbeds").find("#"+thisId+"").remove();

					$(nowDelBed).remove();
					$(".modelbg").hide();
					$(".confirmbox").hide();
					setTimeout(function(){listenAddBed();},1000)

					listenAddPerson();
					listenBedHover();
					listenListenBt();
					listenCloseTishi();
					listenShowPrint();
					listenDelBed();
				}
			})
		}
		//单击温度框弹出温度表单窗口
		function showDegreeTable(){
			//stopAutoRefresh();//停止自动刷新页面
			$(".bedmoreinfo").show();
		}
		//监听鼠标经过病床
		function listenBedHover(){
			var tempTimer;
			$(".bedbox > .normal > .degree ").off("hover")
			$(".bedbox >  .normal > .degree").hover(
				function(e){
					var prototype = $(this).parent()[0];
					var bedid = $(prototype).attr("bedid");//id
					currentBedName=bedid;//将当前床位id存到全局变量中
					//alert(bedid);
					var nowaboutinfo = bedsOtherinfo[bedid];
					var nowaboutinfoBed = bedsBasicinfo[bedid];
					currentBedId=nowaboutinfoBed.idofbed;//将当前床位id存到全局变量中
					//alert(nowaboutinfo.personid);
					//给chat赋值
					var contentInfo="<table style='width:100%'>";
					contentInfo+="<tr><td>监控范围："+nowaboutinfoBed.range+"℃</td><td>监控时间："+nowaboutinfoBed.listentime+"</td><td>贴片号码："+nowaboutinfoBed.num+"</td>";
					contentInfo+="<tr><td>剩余时间：约"+nowaboutinfoBed.surplustime+"小时</td><td>病人信息："+nowaboutinfoBed.personinfo+"</td><td>医师诊断："+nowaboutinfoBed.diagnosis+"</td>";
					contentInfo+="<tr><td>入院时间："+nowaboutinfoBed.roomtime+"</td><td>病案号码："+nowaboutinfoBed.sicknum+"</td><td>主治医师："+nowaboutinfoBed.doctor+"</td>";
					contentInfo= contentInfo+"</table>";
					$(".bedmoreinfo > .personid").html(contentInfo);
					outpatientid=$(prototype).attr("patientid");
					var str =$(prototype).attr("roomtime");
					// 转换日期格式
					str = str.replace(/-/g, '/'); // "2010/08/01";
					$("#day1").text($(prototype).attr("roomtime"));
					// 创建日期对象
					var date = new Date(str);
					// 加一天
					date.setDate(date.getDate()+1);//获取AddDayCount天后的日期
				    var y = date.getFullYear();
				    var m = date.getMonth()+1;//获取当前月份的日期
				    var d = date.getDate();
					$("#day2").text(y+"-"+m+"-"+d);
					//chartObj.xAxis[0].setCategories(nowaboutinfo.times);
					chartObj.series[0].setData(nowaboutinfo.degrees);
					//chartObj.series[0].setData([35,36,37,35,36,37,39,38,36,37,39,37,37,35,36,37,37,37,37,37,37,37,37,37]);
					
					startHour=nowaboutinfo.times;
					//alert(startHour);
					if(startHour==null||startHour==undefined)startHour=2;
					//****************************************************如果温度数据数量不够一天则显示一天的日期
					if (nowaboutinfo.degrees.length>0&&(startHour+(nowaboutinfo.degrees.length-1)*2)<=24) {
						$("#day2").css("display","none");
						$("#day1").css("width","600px");

					}else{
						$("#day2").css("display","inline-block");
						$("#day1").css("width","300px");
					}
					//****************************************************

					if(tempTimer){
						clearTimeout(tempTimer);
					}
					tempTimer = setTimeout(function(){
						var left = prototype.offsetLeft;
						var right =  getClientWidth() - prototype.offsetLeft - prototype.offsetWidth;
						var top = prototype.offsetTop;
						var bottom = getClientHeight() - prototype.offsetTop;
						var infoLeft = 0;
						if(left > right){
							infoLeft = left - $(".bedmoreinfo").width();
						}else{
							infoLeft = left+prototype.offsetWidth;
						}
						$(".bedmoreinfo").css({"left":infoLeft+"px","top":top+"px"});//.show()
					},500)
				},
				function(){
					if(tempTimer){
						clearTimeout(tempTimer)
					}
				}
			)
		}
		//添加病床
		function addbed(obj){
			$.ajax({
				type:"post",
				url:"add.action",//"tiwen/addbed.json",
				dataType:"json",
				data:{"bedid":$(".addbedid").val()},
				success:function(data){
					if(data.success == false){ 
						alert("添加失败，请确认要添加的病床号没有重复！");
						return;
					}
					$(obj).before('<li class="addperson" id="'+data.bedid+'" bedName=\"'+data.bedid+'\">' +
							'<div class="lititle"><span class="">'+data.bedid+'</span><span class="contralbox"><span class="close"></span> </span></div>' +
							'<div class="addpersonclick" bedName=\"'+data.bedid+'\" id="'+data.bedid+'"><div class="addpersonbg"></div><div class="addpersontext"> +病人入住</div></div></li>');
					listenAddBed();
					listenAddPerson();
					listenBedHover();
					listenListenBt();
					listenCloseTishi();
					listenShowPrint();
					listenDelBed();
				},
				error:function(data){alert("添加失败");}
			})
		}
		//添加病人
		function sureAddPerson(){
			sureAddPersonCom();
			return;
			var nowbedId = $(nowAddPersonBed).attr("id");//当前添加的病人ID
			var name = $(".addpersonbox").find("input[name=name]").val();//病人姓名
			var sex = $(".addpersonbox").find("input[name=sex]").val();//性别
			var age = $(".addpersonbox").find("input[name=age]").val();//年龄
			var roomtime = $(".addpersonbox").find("input[name=roomtime]").val();//入院时间
			var sickname = $(".addpersonbox").find("input[name=sickname]").val();//所患疾病
			var doctor = $(".addpersonbox").find("input[name=doctor]").val();//主管医生
			var roomid = $(".addpersonbox").find("input[name=roomid]").val();//病房号
			var bedid = $(".addpersonbox").find("input[name=bedid]").val();//病床号
			var cardname = $(".addpersonbox").find("input[name=cardname]").val();//贴片号码
			var highc = $(".addpersonbox").find("select[name=highc]").val();//温度监控范围 最低温度
			var lowc = $(".addpersonbox").find("select[name=lowc]").val();//温度监控范围 最高温度
			var count = $(".addpersonbox").find("input[name=count]").val();//温度采集间隔数字
			var sicktype = $(".addpersonbox").find("select[name=sicktype]").val();//就医类型
			var personid = $(".addpersonbox").find("select[name=personid]").val();//身份证
			var address = $(".addpersonbox").find("select[name=address]").val();//地址
			$.ajax({
				type:"post",
				url:"addperson.json",//添加病人信息
				dataType:"json",
				data:{"sicktype":sicktype,"personid":personid,"address":address,"nowbedId":nowbedId,"name":name,"sex":sex,"age":age,"roomtime":roomtime,"sickname":sickname,"doctor":doctor,"roomid":roomid,"bedid":bedid,"cardname":cardname,"highc":highc,"lowc":lowc,"count":count,},
				success:function(data){
					bedsOtherinfo[nowbedId] = data[nowbedId];//放入病人其他信息中
					var dom = data.data;
					var tempTypeText = "";
					if(dom.state == "high"){
						tempTypeText = "高温";
					}else if(dom.state == "low"){
						tempTypeText = "低温";
					}else{
						tempTypeText = "正常";
					}
					$(nowAddPersonBed).html('' +
							'<div class="lititle"><span class="">'+dom.bedid+'</span><span class="contralbox"><span class="showinfo"></span> <span class="close"></span> </span></div>' +
							'<div class="degree '+dom.state+'">' +
							'<div class="degreebox">' +
							'<div class="num">'+dom.degree+'℃</div>' +
							'<div>'+tempTypeText+'</div>' +
							'</div>' +
							'</div>' +
							'<div class="personinfo">' +
							'<div>监控范围：'+dom.range+'℃</div>' +
							'<div>监控时间：'+dom.listentime+'</div>' +
							//'<div>采集间隔：'+dom.interval+'分钟</div>' +
							'<div>贴片号码：'+dom.num+'</div>' +
							'<div>剩余时间：约'+dom.surplustime+'小时</div>' +
							'<div class="line"></div>' +
							'<div>病人信息：'+dom.personinfo+'</div>' +
							'<div>医师诊断：'+dom.diagnosis+'</div>' +
							'<div>入院时间：'+dom.roomtime+'</div>' +
							'<div>病案号码：'+dom.sicknum+'</div>' +
							'<div>主治医师：'+dom.doctor+'</div>' +
							'</div>' +
							'<div class="listenbt" >出院</div>' +
							'<div class="printbox"  imgurl="'+dom.pringurl+'"><img src=""><a  href="javascript:void(0)" class="printbt">打印</a></div>');
					$(nowAddPersonBed).off("click");
					$(nowAddPersonBed).attr("class","normal");
					$(nowAddPersonBed).attr("patientid",dom.patientid);
					listenAddBed();
					listenAddPerson();
					listenBedHover();
					listenListenBt();
					listenCloseTishi();
					listenShowPrint();
					listenDelBed();
					$('.addpersonbox').hide();
					$('.modelbg').hide()
				}

			})
		}
		//去后台请求所有病床信息数据
		function getBedsData(){
			$.ajax({
				type:"post",
				url:"listAll.action",//"bed/listAll.action",//"tiwen/bedinfo.json",
				dataType:"json",
				data:{},
				success:function(data){
					$(".totalcount").html(data.total)
					bedsinfo = data.data;
					bedsOtherinfo = data.otherdata;
					putBedsData(bedsinfo);
					listenAddBed();
					listenAddPerson();
					listenBedHover();
					listenListenBt();
					listenCloseTishi();
					listenShowPrint();
					listenDelBed();
				},
				error:function(data){
					listenAddBed();
					listenAddPerson();
					listenBedHover();
					listenListenBt();
					listenCloseTishi();
					listenShowPrint();
					listenDelBed();
				}
			})
		}
		//放入病床信息数据
		function putBedsData(data){
			var highcount = 0;
			$(".normalbeds").empty();
			$(".abnormalbeds").empty();
			$(data).each(function(index,dom) {
				//alert(dom.bedstate);
				if(dom.bedstate == "empty"){
					$(".normalbeds").append('<li class="addperson" bedName=\"'+dom.bedid+'\" id="'+dom.bedid+'" patientid="">' +
							'<div class="lititle"><span class="">'+dom.bedid+'</span><span class="contralbox"><span class="close"></span> </span></div>' +
							'<div class="addpersonclick" bedName=\"'+dom.bedid+'\" id="'+dom.bedid+'"><div class="addpersonbg"></div><div class="addpersontext"> +病人入住</div></div></li>');
					//continue;
				}
				else{
					//alert(dom.state);
					var tempTypeText = "";
					if(dom.state == "high"){
						tempTypeText = "高温";
					}else if(dom.state == "low"){
						tempTypeText = "低温";
					}else{
						tempTypeText = "正常";
						dom.state="normal";
					}
					//获取贴片的工作状态，如出现故障则在病床号后边加叹号作为标志
					var statusOfDevice="";
					if(dom.deviceStatus==0){
						statusOfDevice="(!)";
					}
					
					bedsBasicinfo[dom.bedid]=dom;
					var nowdegree=(dom.degree==undefined)?'36.66':dom.degree;
					var strpersonalinfo=dom.personinfo;
					var seximgurl=(strpersonalinfo.indexOf("-女-")>0)?"../images/woman.ico":"../images/man.ico";
					$(".normalbeds").append('' +
							'<li class="normal" id="'+dom.idofbed+'" bedid="'+dom.bedid+'" roomtime="'+dom.roomtime+'" patientid="'+dom.patientid+'">' +
								'<div class="lititle"><span class="">'+dom.bedid+statusOfDevice+'</span><span class="contralbox"><span class="showinfo"></span> <span class="close"></span> </span></div>' +
								'<div onclick="showDegreeTable()" class="degree '+dom.state+'">' +
										'<div class="degreebox">' +
										'<div class="num">'+nowdegree+'℃</div>' +
								'<div>'+tempTypeText+'</div>' +
								'</div>' +
								'</div>' +
								'<div class="personinfo">' +
										//'<div>病人信息：'+dom.personinfo+'</div>' +
										'<div>'+dom.name+'&nbsp&nbsp<img margin-top="10px" height="14px" src="'+seximgurl+'">&nbsp&nbsp'+dom.age+"岁"+'</div>' +
								'</div>' +
								//'<div class="listenbt" patientid="'+dom.patientid+'">出院</div>' +
								'<div class="printbox"  imgurl="'+dom.pringurl+'"><img src=""><a  href="javascript:void(0)" class="printbt">打印</a></div>'+
							'</li>')
							if(dom.state == "high"){
								highcount++;
								$(".abnormalbeds").append('' +
										'<li class="normal" id="'+dom.idofbed+'"  bedid="'+dom.bedid+'" roomtime="'+dom.roomtime+'" patientid="'+dom.patientid+'">' +
										'<div class="lititle"><span class="">'+dom.bedid+statusOfDevice+'</span><span class="contralbox"><span class="showinfo"></span> <span class="close"></span> </span></div>' +
										'<div onclick="showDegreeTable()" class="degree '+dom.state+'">' +
										'<div class="degreebox">' +
										'<div class="num">'+nowdegree+'℃</div>' +
										'<div>'+tempTypeText+'</div>' +
										'</div>' +
										'</div>' +
										'<div class="personinfo">' +
										'<div class="line"></div>' +
										//'<div>病人信息：'+dom.personinfo+'</div>' +
										'<div>'+dom.name+'&nbsp&nbsp<img margin-top="10px" height="14px" src="'+seximgurl+'">&nbsp&nbsp'+dom.age+"岁"+'</div>' +
										'</div>' +
										'<div class="listenbt" patientid="'+dom.patientid+'">出院</div>' +
										'<div class="printbox"  imgurl="'+dom.pringurl+'"><img src="" ><a  href="javascript:void(0)" class="printbt">打印</a></div>'+
										'</li>')
							}
					//获取贴片的电量
					var powerNum=dom.powerNum;
					if(powerNum!=undefined&&powerNum<=10){
						//alert(dom.bedid+"床电量不足，剩余电量为："+powerNum+"%");
						setTimeout("alert('"+dom.bedid+"床电量不足，剩余电量为："+powerNum+"%')",500);
					}
				}
				
			})
			$(".normalbeds").append('<li class="addbed"><div class="addbedbg"></div><div class="addbedtext"> +添加床位</div></li>');
			$(".highcount").html(highcount);
			if(highcount == 0){
				$(".infobox").hide();
			}
		}
	</script>
	<script type="text/javascript">
		$(function () {
			chartObj =  new Highcharts.Chart({
				chart: {
					spacingTop: 20,
					renderTo: 'container',
					//defaultSeriesType: 'line' //图表类别，可取值有：line、spline、area、areaspline、bar、column等
				},
				title: {
					text: '',
				},
				xAxis: {
					tickmarkPlacement:'between',//'on',
					tickInterval: 1,
					minorTickInterval: 0.5,
					gridLineWidth: 2,
					labels:{
						formatter:function(){
							if((this.value*2+startHour)>24){
								return (this.value*2+startHour)-24 ;
							}else{
								return this.value*2+startHour ;
							}

						}
					}
				},
				yAxis: {
					title: {
						text: ''
					},
					minorTickInterval:"auto",
					minorGridLineWidth: 1,
					gridLineWidth: 2,//副格线的宽度
					labels:{},
					min: 35,
					max: 42,                        //显示的最大值
					maxPadding: 2,
				},
				tooltip: {
					valueSuffix: '°C'
				},
				legend: {
					enabled:false
				},
				exporting:{enabled:false},
				series: [{
					name: '',
					data: [35,36,37,35,36,37,39,38,36,37,39,37,37]
				}],
				credits:{enabled:false}
			});
		});

	</script>
</head>
<body>
	<div id="page">
		<div class="header clearfix">
			<div class="headermain clearfix">
				<div class="logo"><span style="font-size:8px;margin-left:70px;color:white;margin-top:40px;display:block;" >v1.1.1.20151129_ release</span></div>
				<div class="nav"><a href="${ctx }/bed/degreelisten.action" class="checked">温度监控</a><a href="${ctx }/patient/index.action">档案管理</a><!-- <a href="deviceManage.html">设备管理</a> --> </div>
 				<div class="logininfo"><span>${user_attr.realName }</span><input id="user_attr_id" type="hidden" value="${user_attr.id }"></div>
			</div>
		</div>
		<div class="main">
			<div class="roombox clearfix">
				<div class="infobox"><span><span class="highcount"> 0 </span><span>位病人温度出现异常，请立即关注</span></span><span class="closeinfo"><span>知道了，关闭提示</span><span class="closecirle"></span></span> </div>
				<div class="bedbox abnormalbeds clearfix">

				</div>
			</div>
			<div class="roombox clearfix">
				<div class="title">现共有床位<span class="totalcount">0</span>个</div>
				<div class="bedbox normalbeds clearfix">
					
					<li class="addbed"><div class="addbedbg"></div><div class="addbedtext"> +添加床位</div></li>
				</div>
			</div>
		</div>
    </div>
	<div class="bedmoreinfo">
		<div id="container" style="width: 650px; height: 400px; margin: 10px  auto 0px auto; "></div>
		<div  style="width: 650px; top:-15px; left: 17px; position: relative; font-size: 12px; height: 16px;text-align: center"><div id="day1" style="border:solid 1px #ccc;display: inline-block; width: 300px; border-right: none">2015.11.18</div><div id="day2" style="border:solid 1px #ccc;display: inline-block; width: 300px;">2015.11.19</div> </div>
		<div class="personid" style="margin-top: -8px">
		</div>
		<div style="padding:5px;"><input type="button" class="showinfo" onclick="" value="打印体温表" ><input type="button" class="listenbt" onclick="" value="出院"><input type="button" onclick="changeDepartment();" value="转科室"><input type="button" onclick="$('.bedmoreinfo').hide();" value="关闭"></div>
	</div>
	<div class="changeBedDialog">
		<!-- <div id="container" style="width: 650px; height: 400px; margin: 10px  auto 0px auto; "></div> -->
		<div style="margin:10px;">
		<span style="margin:10px;">请选择科室：</span><select id="selDepartment" onchange="InitBedsByDepartment();" style="width:100px;"></select>
		<br>
		</div>
		<div style="margin:10px;">
		<span style="margin:10px;">请选择床位：</span><select id="selBed" style="width:100px;"></select>
		</div>
		<div style="margin:10px;">
		<div style="padding:5px;"><input type="button" onclick="sureChangeDepartment();" value="确认"><input type="button" onclick="$('.changeBedDialog').hide();" value="关闭"></div>
		</div>
	</div>
	<div class="modelbg"></div>
	<div class="confirmbox">
		<div class="text" >确认删除吗？</div>
		<a href="javascript:void(0)" class="yes">确认</a><a href="javascript:void(0)" class="cancel">取消</a>
	</div>
	<div class="confirmstopbox">
		<div class="text" >确认终止监控吗？</div>
		<a href="javascript:void(0)" class="yesstop" onclick="stopListen()">确认</a><a href="javascript:void(0)" class="cancelstop" onclick="$('.modelbg').hide();$('.confirmstopbox').hide();">取消</a>
	</div>
	<div class="confirmoutbox">
		<div class="text" >确认出院吗？</div>
		<a href="javascript:void(0)" class="yesout">确认</a><a href="javascript:void(0)" class="cancelout" onclick="$('.modelbg').hide();$('.confirmoutbox').hide();">取消</a>
	</div>
	<div class="addpersonbox">
		<div class="text" >
			<div class="title">添加病人</div>
			<div class="nav"><a href="javascript:void(0)" class="checked personbt" onclick="$('.persontab').show();$('.tiepiantab').hide();$('.tiepianbt').removeClass('checked');$(this).addClass('checked')">病人信息</a>
				<a href="javascript:void(0)" class="tiepianbt" onclick="$('.persontab').hide();$('.tiepiantab').show();$('.personbt').removeClass('checked');$(this).addClass('checked')">贴片信息</a> </div>
			<table class="persontab">
				<tr><td>病人姓名</td><td><input id="patientid" type="hidden"><input name="name" type="text"></td></tr>
				<tr><td>性别</td><td>&nbsp;<input name="sex" type="radio" value="男"> &nbsp;男 &nbsp;&nbsp;<input name="sex" type="radio" value="女">&nbsp;女</td></tr>
				<tr><td>年龄</td><td><input name="age" type="text" maxlength="3" onkeyup="this.value=this.value.replace(/\D/g,'')"  onafterpaste="this.value=this.value.replace(/\D/g,'')"></td></tr>
				<tr><td>入院时间</td><td><input name="roomtime" id="startTime" style=" cursor: pointer" class="Wdate" type="text"
				onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',readOnly:false})"></td></tr>
				<tr><td>病案号码</td><td><input name="sicknum" type="text"></td></tr>
				<tr><td>医师诊断</td><td><input name="sickname" type="text"></td></tr>
				<tr><td>主管医生</td><td><input name="doctor" type="text"></td></tr>
				<tr><td>病床号</td><td><input id="bedid" name="bedid" type="text"><input id="idofbed" name="idofbed" type="hidden"></td></tr>
				<tr><td>身份证</td><td><input name="personid" type="text" maxlength="18" onkeyup="this.value=this.value.replace(/\D/g,'')"  onafterpaste="this.value=this.value.replace(/\D/g,'')"></td></tr>
				<tr><td>住址</td><td><input name="address" type="text"></td></tr>
				<tr><td>就医类型</td><td><input name="sicktype" type="text"></td></tr>
			</table>
			<table class="tiepiantab" style="display: none">
				<tr><td>贴片号码</td><td><input name="cardname" type="text" maxlength="12"></td></tr>
				<tr><td>温度监控范围</td><td><select name="lowc"><option>35</option><option>36</option><option>37</option><option>38</option><option>39</option></select> ~ <select name="highc"><option>41</option><option>40</option><option>39</option><option>38</option><option>37</option></select></td></tr>
			</table>
		</div>
		<a href="javascript:void(0)" class="" onclick="sureAddPerson()">确认</a><a href="javascript:void(0)" class="" onclick="$('.addpersonbox').hide();$('.modelbg').hide()">关闭</a>
	</div>

	<div class="updpwdbox">
		<div class="text" >
			<div class="title">修改密码</div>
			<table class="persontab">
				<tr><td>原密码</td><td><input name="oldpwd" type="password"></td></tr>
				<tr><td>新密码</td><td><input name="newpwd" type="password"></td></tr>
				<tr><td>确认新密码</td><td><input name="surenewpwd" type="password"></td></tr>
			</table>
		</div>
		<a href="javascript:void(0)" class="" onclick="updpwd()">确认</a><a href="javascript:void(0)" class="" onclick="closeupdpwd()">关闭</a>
	</div>

	<div class="putbedidbox">
		<div class="text" >
			<div class="title">请填写病床ID
			</div>
			<table class="persontab">
				<tr><td>病床ID</td><td><input class="addbedid" type="text"></td></tr>
			</table>
		</div>
		<a href="javascript:void(0)" class="" onclick="$('.modelbg').hide();$('.putbedidbox').hide();addbed(nowaddBed);">确认</a><a href="javascript:void(0)" class="" onclick="$('.modelbg').hide();$('.putbedidbox').hide();">关闭</a>
	</div>
<script>
</script>
</body>
</html>